<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<?php $this->load->view('admin/header.html')?>
<script type="text/javascript" src="http://www.st.com/common/js/validateForm.js"></script>
<?php echo !empty($init) && $init==1? '<script type="text/javascript">$(function(){parent.manage_menu();})</script>':"" ?>
<script type="text/javascript">
    function Success(data) {
        $.Success(data);
        setTimeout(function () { window.location.href = window.location.href; }, 3000);
    }
    function EditUse(mid, state) {
        $.post('/admin/menu/setuse', { 'mid': mid, 'state': state }, function (data) {
            var jsonData = $.parseJSON(data);

            if (jsonData.Statu == 'ok') {
                alert(jsonData.Msg);
                location.href = jsonData.BackUrl;
            }
            else {
                alert(jsonData.Msg);
            }
        });
    }

    function Del_Child(menuid) {
        url = "/admin/menu/del_child_menu/" + menuid;
        layer.confirm("删除此栏目，其所有子集栏目都会删除，确定删除？", function () {
            $.post(url, null, function (data) {
                var jsonData = $.parseJSON(data);
                if (jsonData.Statu == 'ok') {
                    Success(jsonData)
                }
                else {
                    Success(jsonData)
                }
            })
        }, function () {
            layer.msg('取消删除', { icon: 0 });
        })
    }

     function add_child_menu() {
        url = "<?php echo site_url('admin/menu/add_child_menu/'.$parentid)?>";
        layer.open({
            type: 2,
            title: '栏目添加',
            maxmin: true,
            shadeClose: false,
            area: ['600px', '400px'],
            offset: ['100px', ''],
            content: url,
        });
     }

    function edit_child_menu(menuid) {
        var url = "<?php echo site_url('admin/menu/edit_child_menu/{menuid}')?>";
        url = url.replace(/{menuid}/, menuid);
        layer.open({
            type: 2,
            title: '栏目修改',
            maxmin: true,
            shadeClose: false,
            area: ['600px', '400px'],
            offset: ['100px', ''],
            content: url,
        });
    }

    $(function () {
        $(".tableBasic .form_weight").each(function () {
            var itemsId = $(this).attr('id');
            $.validate_Weight(itemsId);
        });
    });
</script>
<div id="dcMain">
    <!-- 当前位置 -->
    <div id="urHere">
        DouPHP 管理中心

        <?php foreach($crumbs_items as $crumbs_item):?>
        <b>></b><a href="<?php echo $crumbs_item[0]?>"><?php echo $crumbs_item[1]?></a>
        <?php endforeach;?>
    </div>
    <div id="manager" class="mainBox" style="height:auto!important;height:550px;min-height:550px;">
        <h3>
           
        </h3>
        <table width="100%" border="0" cellpadding="8" cellspacing="0" class="tableBasic">
            <tr>
                <th width="30" align="center">编号</th>
                <th align="left">栏目名称</th>
                <th align="center">权重</th>
                <th align="center">操作</th>
            </tr>
            <?php foreach($childs as $menu_child_item):?>
            <tr>
                <td align="center"><?php echo $menu_child_item->menuid;?></td>
                <td><?php echo $menu_child_item->title;?></td>
                <td align="center">
                    <form class="form_weight" id="ajax_form_<?php echo $menu_child_item->menuid?>" method="post" action="<?php echo site_url('admin/menu/set_menu_weight/'.$menu_child_item->menuid)?>?returnurl=<?php echo 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']?>">
                        <input type="text" name="weight" id="<?php echo $menu_child_item->menuid?>" value="<?php echo $menu_child_item->weight?>" /><input type="submit" value="更新" style="color:#666;width:40px;margin-left:20px;" />
                    </form>
                </td>
                <td align="center">
                    <?php 
                    $menu_url=$menu_child_item->child==1?site_url('admin/menu/menulist/'.$menu_child_item->menuid):site_url('admin/'.$menu_child_item->menu_control.'/'.$menu_child_item->menu_action.($menu_child_item->page_type==1?'list':'info').'/'.$menu_child_item->menuid);
                    ?>
                    <a href="<?php echo $menu_url?>">管理</a>
                    <!--<a href="javascript:edit_child_menu(<?php echo $menu_child_item->menuid?>)">修改</a>|
                    <a href="javascript:Del_Child(<?php echo $menu_child_item->menuid?>)">删除</a>-->
                </td>
            </tr>
            <?php endforeach; ?>
        </table>
        <div class='page'>
        </div>
    </div>
</div>
